/*
 * OpennavMapProvider.h
 *
 *  Created on: 25.02.2011
 *      Author: Markus
 */

#ifndef OPENNAVMAPSERVICEPROVIDER_H_
#define OPENNAVMAPSERVICEPROVIDER_H_

#include <FBase.h>
#include <FLocations.h>
#include <FGraphics.h>
#include <Opennav.h>
#include "OpennavMap.h"

using namespace Osp::Base::Runtime;
using namespace Osp::Graphics;

class OpennavMapServiceProvider : private IRunnable {
public:
	class IOpennavMapProviderListener {
	public:
		virtual void OnMapRequestFinished(OpennavMapSection* section, int requestId) = 0;
	};
public:
	OpennavMapServiceProvider();
	~OpennavMapServiceProvider();
	result Construct(OpennavMap* map);
	void AddOpennavMapProviderListener(IOpennavMapProviderListener& listener);
	int RequestMap(Osp::Locations::Coordinates& mapCenter, float zoomLevel, float azimuth, int width, int height);
public:
	Osp::Base::Object* Run(void);

private:
	OpennavMap* __pMap;
	Thread* __pRenderWorker;
	Mutex* __pLock;
	IOpennavMapProviderListener* __pListener;
	bool __kill;
	bool __render;
	Osp::Locations::Coordinates __mapCenter;
	float __zoomLevel, __azimuth;
	int __width, __height, __requestId;
};

#endif /* OPENNAVMAPSERVICEPROVIDER_H_ */
